package com.example.gybicycle.controller.web;

import com.example.gybicycle.common.entity.Result;
import com.example.gybicycle.dao.IndexDao;
import com.example.gybicycle.entity.index.Index;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "首页")
@RestController
@RequestMapping("/web/index")
public class IndexContoller {
    @Autowired
    private IndexDao indexDao;
    @PostMapping("")
    @Operation(summary = "首页数据")
    public Result<Index> testIndex(){
        Index index=new Index();
        index.setIncome(indexDao.findRevenueCount());
        index.setDayByCycling(indexDao.findCycleNum(1));
        index.setDayByCycle(indexDao.findCycleStateCount());
        index.setDayByIncome(indexDao.findCycleMoney(1));
        index.setFailurelist(indexDao.findFailure());
        index.setFailureHandle(indexDao.findFailureHandle());
        index.setCyclingMaps(indexDao.findCyclingMap());
        return Result.success(index);
    }
}
